package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;

/**
 * 工班解锁详情VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/6/17 15:44
 */
@Data
public class OneStockTallyUnlockDetailVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long id;

    /** 货运舱单ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "货运舱单ID",notes = "")
    private Long transportShipId ;

    /** 货运舱单ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "货运舱单ID",notes = "")
    private Long transportBillId ;

    @ApiModelProperty(value = "船名")
    private String shipNameZh;

    @ApiModelProperty(value = "货名")
    private String billCargoType;

    @ApiModelProperty(value = "货名")
    private String billCargoTypeName;

    @ApiModelProperty(value = "航次")
    private String voyage;

    @ApiModelProperty(value = "进出口")
    private String iE;

    @ApiModelProperty(value = "进出口")
    private String iEName;

    public String getiEName() {
        switch (iE) {
            case "I":
                return "进口";
            case "E":
                return "出口";
            default:
                return "";
        }
    }

    @ApiModelProperty(value = "舱单号")
    private String billNo;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    @ApiModelProperty(value = "时间段")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "理货类型")
    private String tallyType;

    @ApiModelProperty(value = "理货类型")
    private String tallyTypeName;

    public String getTallyTypeName() {
        if (Func.isNull(tallyType)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TALLY_TYPE, tallyType);
    }

    @ApiModelProperty(value = "理货包装")
    private String tallyPackageType;

    @ApiModelProperty(value = "理货包装")
    private String tallyPackageTypeName;

    @ApiModelProperty(value = "理货件数")
    private Integer tallyPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "理货吨数")
    private BigDecimal tallyTon;

    @ApiModelProperty(value = "航陆运")
    private String shipLand;

    @ApiModelProperty(value = "航陆运")
    private String shipLandName;

    public String getShipLandName() {
        if (Func.isNull(shipLand)) {
            return "";
        }
        return DictBizCache.getValue("ship_land", shipLand);
    }

    @ApiModelProperty(value = "作业过程")
    private String operationType;

    @ApiModelProperty(value = "作业过程")
    private String operationTypeName;

    @ApiModelProperty(value = "作业活动")
    private String workActivity;

    @ApiModelProperty(value = "作业活动")
    private String workActivityName;

    /** 保管员 */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "保管员",notes = "")
    private Long keeper ;

    /** 保管员 */
    @ApiModelProperty(name = "保管员",notes = "")
    private String keeperName ;

    /** 安全生产 */
    @ApiModelProperty(name = "安全生产",notes = "")
    private String isSafeProduction ;

    /** 安全生产 */
    @ApiModelProperty(name = "安全生产",notes = "")
    private String isSafeProductionName ;

    public String getIsSafeProductionName() {
        if (Func.isNull(isSafeProduction)) {
            return "";
        }
        return "Y".equals(isSafeProduction) ? "是" : "否";
    }

    /** 影响货垛ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "影响货垛ID")
    private Long affectStorageId;

    /** 区域ID */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "区域ID",notes = "")
    private Long storageAreaId ;

    /** 区域 */
    @ApiModelProperty(name = "区域",notes = "")
    private String storageAreaName ;

    /** 货场 */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "货场",notes = "")
    private Long storagePositionId ;

    /** 货场 */
    @ApiModelProperty(name = "货场",notes = "")
    private String storagePositionName ;

    /** 货位 */
    @ApiModelProperty(name = "货位",notes = "")
    private String storageSpot ;

    @ApiModelProperty(value = "货位")
    private String positionInfo;

    public String getPositionInfo() {
        if (Func.isNull(storagePositionName) || Func.isNull(storageSpot)) {
            return "";
        }
        return storagePositionName + "/" + storageSpot;
    }

    /** 备注 */
    @ApiModelProperty(name = "备注",notes = "")
    private String remark ;

    /** 货位 */
    @ApiModelProperty(name = "舱口",notes = "")
    private String hold ;

    /** 货位 */
    @ApiModelProperty(name = "舱口",notes = "")
    private String holdName ;

    /** 队组全名 */
    @ApiModelProperty(name = "队组全名",notes = "")
    private String workerInfo ;

    /** 车数 */
    @ApiModelProperty(name = "车数",notes = "")
    private String cars ;

    /** 是否退关 */
    @ApiModelProperty(name = "是否退关",notes = "")
    private String isRetreat ;

    /** 机械信息 */
    @ApiModelProperty(name = "机械信息",notes = "")
    private String machineInfo ;

    /** 出库时间 */
    @ApiModelProperty(name = "出库时间",notes = "")
    private String outTimeSpace ;

    @ApiModelProperty(value = "出库时间")
    private String outTimeSpaceName;

    public String getOutTimeSpaceName() {
        if (Func.isNull(outTimeSpaceName)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.OUT_TIMES, outTimeSpace);
    }

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "理货员",notes = "")
    private Long createUser ;

    @ApiModelProperty(name = "理货员",notes = "")
    private String createUserName ;

    @ApiModelProperty(name = "货主",notes = "")
    private String cargoOwner ;

    @ApiModelProperty(name = "货主",notes = "")
    private String cargoOwnerName ;

    @ApiModelProperty(name = "联系电话",notes = "")
    private String contactPhone ;

    @ApiModelProperty(name = "包装",notes = "")
    private String packageType ;

    @ApiModelProperty(name = "包装",notes = "")
    private String packageTypeName ;

    @ApiModelProperty(value = "计划件数")
    private Integer planPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "计划吨数")
    private BigDecimal planTon;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "单吨")
    private BigDecimal perTon;

    public BigDecimal getPerTon() {
        if (Func.isNull(planPiece) || Func.isNull(planTon) || planPiece == 0 || "BU".equals(packageType)) {
            return new BigDecimal(0);
        }
        return planTon.divide(new BigDecimal(planPiece), RoundingMode.CEILING).stripTrailingZeros();
    }

    @ApiModelProperty(name = "计划泊位",notes = "")
    private String planBerth ;

    @ApiModelProperty(name = "计划泊位",notes = "")
    private String planBerthName ;

    @ApiModelProperty(name = "实际泊位",notes = "")
    private String lastBerth ;

    @ApiModelProperty(name = "实际泊位",notes = "")
    private String lastBerthName ;
}
